package com.liang.service.impl;

import com.liang.dao.MovieTypeMapper;
import com.liang.pojo.MovieType;
import com.liang.service.MovieTypeService;
import com.liang.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.math.BigInteger;
import java.util.List;

public class MovieTypeServiceImpl implements MovieTypeService {
    private SqlSession sqlSession =null;

    public BigInteger[] getMovieType(int movieId) {
        sqlSession = MybatisUtils.getSqlSession();
        MovieTypeMapper mapper = sqlSession.getMapper(MovieTypeMapper.class);
        List<MovieType> movieType = mapper.getMovieType(movieId);
        BigInteger[] labelID= new BigInteger[movieType.size()];
        int i=0;
        for (MovieType type : movieType) {
            labelID[i]=type.getLabelId();
            i+=1;
        }
        sqlSession.close();
        return labelID;
    }
}
